<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>woker manage</title>
    <style>
        table{border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;margin: auto}
        th,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
        th{font-weight:bold;}
        body{text-align: center}
    </style>
    {% load static %}
    <script type='text/javascript' src="/static/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("input[name='submit']").click(function(){
                var status = 0;
                var userId = $(this).parent().prev().children().val();
                var crf = $("input[name='csrfmiddlewaretoken']").val();
                if($(this).parent().prev().children().is(':checked')) {
                    status = 1;
                }
                $.ajax({
                    url:'workerManage',
                    type:'POST',
                    data:{status:status,userId:userId,csrfmiddlewaretoken:crf},
                    success:function(data){
                        if(data=='1'){
                            alert('修改成功');
                        }else{
                            alert('修改失败');
                        }
                    }
                });
            });
        });
    </script>
</head>
<body>
    <table>
        <tr>
            <td colspan="4">工作人员管理</td>
        </tr>
        <tr>
            <td>登录名</td>
            <td>显示名</td>
            <td>状态</td>
            <td>操作</td>
        </tr>
        {% for user in users %}
        <tr>
            <td>{{ user.userName }}</td>
            <td>{{ user.showName }}</td>
            <td>
                <input type="checkbox" value="{{ user.id }}" {% if user.status == '1' %}checked{% endif %}/>启用
            </td>
            <td><input type="button" name="submit" value="确定"/></td>
        </tr>
        {% endfor %}
    </table>
    {% csrf_token %}
</body>
</html>